package com.raymond.queue.client.service;

import com.alibaba.fastjson.JSONObject;
import com.raymond.queue.client.thread.AsyncTaskHandleThread;
import com.raymond.queue.common.msg.BaseMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * 生产回调处理
 *
 * @author :  raymond
 * @version :  V1.0
 * @date :  2021-07-14 11:39
 */
public class ProductionCallBack implements Callback {

    private final static Logger logger = LoggerFactory.getLogger(ProductionCallBack.class);

    AtomicInteger atomicInteger = new AtomicInteger();
    @Override
    public void callback(BaseMessage req, BaseMessage resp) {
        atomicInteger.getAndIncrement();
    }

    @Override
    public void sendFailCallback(BaseMessage req, int code) {
//        atomicInteger.getAndIncrement();
//        logger.debug("推送失败：{},code:{}", JSONObject.toJSONString(req), code);
        logger.debug("推送失败,code:{}", code);
    }

    public int get() {
        return atomicInteger.get();
    }
}
